from django import forms
from .models import User as Muser


class User(forms.ModelForm):
    password_1 = forms.CharField(max_length=16, min_length=6)

    def clean(self):
        clean_data = super(User, self).clean()
        password1 = clean_data.get("password")
        password2 = clean_data.get("password_1")
        if password1 != password2:
            raise forms.ValidationError("验证失败")

    class Meta:
        model = Muser
        fields = "__all__"


class Sign(forms.ModelForm):
    class Meta:
        model = Muser
        fields = ["username", "password"]
